<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理员管理</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
</head>
<body>
<div class="x-body">
		<h4 class="sub_title">
			<#if org??>
			${org.name}
			<#else>
				全部机构
			</#if>
			<a href="javascript:topOpen('添加员工','/staff/form.htm','700','500');" class="add_btn">添加员工</a>
		</h4>
		<div class="layui-row">
            <form action="/staff/list.htm" method="get" class="layui-form">
            		<div class="layui-inline">
                    <select name="searchType" lay-filter="aihao">
                        <option value="">全部</option>
                        <option value="userLoginId" <#if query.searchType=='userLoginId'>selected</#if>>账户</option>
                        <option value="name" <#if query.searchType=='name'>selected</#if>>姓名</option>
                        <option value="mobile" <#if query.searchType=='mobile'>selected</#if>>手机号</option>
                    </select>
                </div>
                
                 <div class="layui-inline">
                    <input type="text" name="searchKey" value="${query.searchKey}" lay-verify="title" autocomplete="off" placeholder="搜索内容" class="layui-input">
                </div>
                
                <div class="layui-input-inline ">
                    <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon"></i>搜索</button>
                </div>
                
                 <div class="layui-input-inline">
                    <a href="/staff/downtemp.htm" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe601;</i>下载模板</a>
                </div>
                
                 <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="upload"><i class="layui-icon"></i>批量导入</button>
                </div>
                
            </form>
        </div>
        <table class="layui-table mytable layui-form" lay-even="" lay-skin="nob">
            
            <thead>
            <tr>
            	<th width="30px">选择</th>
            	<th>手机(账户)</th>
                <th>姓名</th>
                <th>性别</th>
                <th>类型</th>
                <th>部门</th>
                <th>职位</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            	    <#list pm.datas as item>
                <tr>
            		<td>
            			<input type="checkbox" name="ids" value="${item.partyId}" lay-skin="primary">
            		</td>
            		<td>${item.person.mobile}</td>
                    <td>${item.staff.name}</td>
                    <td>
                    	<@linkage type="GENDER" key=item.person.gender>
                    		<span class="${linkage.style}">${linkage.name}</span>
                    	</@linkage>
                    </td>
                    <td>
                    	
                    	
                    	<@linkage type="STAFF_TYPE" key=item.staff.staffType>
                		<span class="${linkage.style}">${linkage.name}</span>
                		</@linkage>
                    
                    </td>
                    <td>${item.staff.department}</td>
                    <td>${item.staff.position}</td>
                    <td>
                    	<@linkage type="STAFF_STATUS" key=item.staff.staffStatus>
                		<span class="${linkage.style}">${linkage.name}</span>
                		</@linkage>
                    </td>
                    <td>
                    
                    	    <a href="javascript:topOpen('修改用户信息','/staff/edit.htm?partyId=${item.partyId}','600','500');">修改</a> 
                    		<#if item.staff.isSystem !='Y'>
                        		| 
                        		<#if item.staff.staffStatus =='NORMAL'>
                        		<a href="javascript:change('冻结后账户不能登录,确定是否冻结','/staff/changeStatus.htm',{partyId:${item.partyId},'staffStatus':'FREEZE'})">冻结</a>
                        		<#else>
                        		<a href="javascript:change('解冻后账户可登录,确定是否解冻','/staff/changeStatus.htm',{partyId:${item.partyId},'staffStatus':'NORMAL'})">解冻</a>
                        		</#if>
                    		</#if>
                    
                    		<#if query.organizationId??>
                    		| <a href="javascript:remove('确认移除员工','/org/removeStaff.htm',{partyId:${item.partyId},organizationId:${query.organizationId}})">移除</a>
                    		</#if>
                    </td>
                </tr>
                </#list>
                
            </tbody>
        </table>
        <div class="layui-row">
		    <div class="layui-col-xs6">
		    	  <div style="margin: 10px 0;">
		    	  		<button class="layui-btn layui-btn-danger layui-btn-sm" id="setting"><i class="layui-icon">&#xe620;</i>批量设置</button>
		    	  </div>
		    </div>
		    <div class="layui-col-xs6">
		      <@p.page pm=pm></@p.page>
		    </div>
		</div>
            
</div>

<script>
layui.use(['upload','element'], function(){
  	  var $ = layui.jquery ,upload = layui.upload,element = layui.element;
  
	  //普通图片上传
	  var uploadInst = upload.render({
	    elem: '#upload'
	    ,exts:'xls'
	    ,url: '/staff/imports.htm'
	    ,done: function(res){
	      
	      if(res.code == 1){
	         layer.msg(res.msg);
	      }else{
	      	layer.msg(res.msg);
	      }
	     
	    }
	    ,error: function(){
	      
	    }
	  });
  
});
</script>
<script>
        layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery, form = layui.form,layer = layui.layer,laydate = layui.laydate;
          
          	$("#setting").click(function(){
          	
          		var $ids =  $("input[name='ids']:checked");
		          if($ids.length <=0 ){
		           	parent.layer.msg('请选择员工');
		           	return false;
		          }
          	
          		parent.layer.open({
			        type: 2,
			        area: ['800px','500px'],
			        maxmin: true,
			        shadeClose: true,
			        shade:0.4,
			        title: '人员机构设置',
			        scrollbar: true,
			        content: '/staff/setting.htm'
			    });
          		
          	
          	});
        });
        
        
        function change(title,url,parms){
        	parent.layer.confirm(title, {icon: 3, title:'提示'}, function(index){
				  //do something
				  if(url){
					  
					  $.ajax({
			      			type:"POST", 
			      			url:url,
			      			data:parms ,
			      			success:function(result) {
					      
					      		if(result.code=='1'){
					      			layer.msg('操作成功');
					      			window.location.reload();
					      		}else{
					      		 	parent.layer.msg(result.msg);
					      		}
					      
					    	 	} 
					    }); 
				  }
			   parent.layer.close(index);
			});
        
        }
        
        function remove(title,url,parms){
	
			parent.layer.confirm(title, {icon: 3, title:'提示'}, function(index){
				  //do something
				  if(url){
					  
					  $.ajax({
			      			type:"POST", 
			      			url:url,
			      			data:parms ,
			      			success:function(result) {
					      
					      		if(result.code=='1'){
					      			layer.msg('操作成功');
					      			window.location.reload();
					      		}else{
					      		 	parent.layer.msg(result.msg);
					      		}
					      
					    	 	} 
					    }); 
				  }
			   parent.layer.close(index);
			});
		}
		
		function topOpen(title,url,w,h){
			parent.layer.open({
		        type: 2,
		        area: [w+'px', h +'px'],
		        maxmin: true,
		        shadeClose: true,
		        shade:0.4,
		        title: title,
		        scrollbar: true,
		        content: url
		    });
		
		}
		
		
		
		
        
    </script>
</body>
</html>